﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%var _forumId = Convert.ToInt32(ViewData["ForumId"]); %>
 <div class="fr-widget white-space">
        <div class="header">
         <div class="collapse collapse-close {collapseId:'#collapse_moderation_tools'}">
            </div>
            <div class="icon">
            </div>
            <span>
                <%=ForumContext.GetText("TOPICS","MODERATION_TOOL") %>
            </span>
        </div>

        <div id="collapse_moderation_tools">
        <%using (Html.BeginForm("Moderator", "Forum", FormMethod.Post, new { @id = "Moderator" }))
          {
  
        %>

        <table cellpadding="0" cellspacing="1" width="100%">
            <tr>
                <td class="table-cell width5">
                    <input type="checkbox" onclick="$.MvcForum.toggleCheckbox(this.checked)" />
                </td>
                <td class="table-cell width20">
                    <select class="select" name="commandType" id="commandType" onchange="onModerationChanging(this.value)">
                    <option value="-1">--</option>
                        <%
                        
                            var _moderateOptions = Enum.GetValues(typeof(ModerateOptions));

                            foreach (int value in _moderateOptions)
                            {
                        %>
                        <option value="<%=value.ToString()%>">
                            <%= ForumContext.GetText("TOPICS","WITH_SELECTED")+ ForumContext.GetText("TOPICS",Enum.GetName(typeof(ModerateOptions), value))%></option>
                        <%
}%>
                    </select>
                    <input type="hidden" id="ids" name="ids" class="hidden" />
                    <input type="hidden" id="forumId" name="forumId" class="hidden" value="<%=_forumId %>" />
                </td>
                <td class="table-cell w20 hidden" id="_priorityDatePanel">
                    <input type="text" value="<%=DateTime.UtcNow.AddDays(365) %>" name="prioritydate" id="prioritydate" class="input datepicker" />
                </td>
                <td class="table-cell width25 hidden" id="_forum_list_panel">
                    <select class="select" style="min-width: 300px" id="moveToForum" name="moveToForum">
                        <%
                            var _forums = ViewData["ForumJump"] as List<ForumsListEntity>;
                            
                            foreach (var forum in _forums)
                            {
                                if (string.IsNullOrEmpty(forum.RemoteUrl))
                                {
  
                        %>
                        <option value="<%=forum.ForumId %>" <%=_forumId==forum.ForumId?" selected=\"selected\"":string.Empty %>>
                            <%=ForumContext.Padding(forum.Level) + Html.Encode(forum.ForumName)%></option>
                        <%
}
                            }%>
                    </select>
                </td>
                <td class="table-cell">
                    <input type="button" class="button" onclick="doAction();" value="<%=ForumContext.GetText("TOPICS","GO") %>"  />
                </td>
            </tr>
        </table>
        <%}
        %>

        </div>
    </div>
    <script type="text/javascript">
     //<![CDATA[//
        function onModerationChanging(_val) {
            if (_val == '<%=(int)ModerateOptions.Move %>') {
                $("#_forum_list_panel").fadeIn();

            }
            else {

                $("#_forum_list_panel").fadeOut();
            };

            if (_val == '<%=(int)ModerateOptions.Pin %>') {
                $("#_priorityDatePanel").fadeIn();
                $('.datepicker').datepicker({

                    yearRange: '-10:+30',
                    changeMonth: true,
                    changeYear: true

                });
            }
            else {

                $("#_priorityDatePanel").fadeOut();
            }
        };

        function doAction() {

            var _cmd = document.getElementById('commandType').value;
            if (_cmd != -1) {
                var _items = $.MvcForum.getSelectedItems();
                if (_items.length > 0) {

                    if (_cmd == '<%=(int)ModerateOptions.Del %>') {
                        if (!confirm('<%=ForumContext.GetMessage("DELETE_POSTS_CONFIRM") %>')) {

                            return;
                        }
                    }
                    $('#ids').val(_items.join(','));
                    $.MvcForum.ajaxSubmit('Moderator');
                }
                else {
                    alert('<%=ForumContext.GetMessage("MUST_SELECT_ITEM") %>');
                }
            }
        }
          //]]>
    </script>